<%@page import="org.apache.taglibs.standard.tag.common.core.ForEachSupport"%>
<%@page import="org.jbit.news.entity.News"%>
<%@page import="org.jbit.news.entity.Page"%>
<%@page import="cn.jbit.NewsService.NewsServiceImpl"%>
<%@page import="cn.jbit.NewsService.NewsService"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
	session.setAttribute("basePath", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新闻中国</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="js/jquery-form.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
	$(function() {
		uname = "${sessionScope.uname}";
		if (uname != "") {
			$("form").hide();
			$("#status").show();
			$("#status").children("span").text(uname);
		} else {
			$("form").show();
			$("#status").hide();
		}
		$("#status input").click(function() {
			location.href = "<%=basePath%>/newspages/admin.jsp";
		});
	});

	function focusOnLogin() {
		$("#uname").focus();
	};
</script>

</head>
<body>
	<div id="header">
		<div id="top_login">
			<form action="test" method="post">
			<div></div>
				<label> 登录名 </label> <input type="text" name="uname" value=""
					class="login_input" id="uname" /> <label> 密&#160;&#160;码 </label>
				<input type="password" name="upwd" value="" class="login_input" />
				<input type="submit" class="login_sub" value="登录" id="subbtn" /> <span
					id="logInfo"></span> <label id="error"> </label> <img
					src="images/friend_logo.gif" alt="Google" id="friend_logo" />
			</form>
			<div id="status" style="display:none;">
				<!-- 登录后显示 -->
				管理员：<span></span> &#160;&#160;&#160;&#160; <a
					href="${sessionScope.basePath}/newspages/loginOut">login out</a> <input
					type="button" value="管理" class="login_sub"
					style="position: relative;left: 50px;" />
			</div>
		</div>
		<div id="nav">
			<div id="logo">
				<img src="images/logo.jpg" alt="新闻中国" />
			</div>
			<div id="a_b01">
				<img src="images/a_b01.gif" style="margin-top: 15px;" />
			</div>
			<!--mainnav end-->
		</div>
	</div>
	<div id="container">
		<div class="sidebar">
			<h1>
				<img src="images/title_1.gif" alt="国内新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<li><a href='#'><b> 景区，如何不再依靠门票收入 </b></a></li>
					<li><a href='#'><b> 高考期间中东部地区将现大范围降雨 </b></a></li>
					<li><a href='#'><b> 山西离柳焦煤集团井下人行车发生事故6人死亡 </b></a></li>
				</ul>
			</div>
			<h1>
				<img src="images/title_2.gif" alt="国际新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<li><a href='#'><b> 习近平在墨国会发表演讲:朋友要老 好酒要陈 </b></a></li>
					<li><a href='#'><b> 普京逮捕铁腕市长展示肌肉向世人表明克宫仍大权在握</b></a></li>
					<li><a href='#'><b> 潘基文祝贺赖斯被任命为美国国家安全顾问 </b></a></li>
					<li><a href='#'><b> 与基地有关组织宣称对巴格达连环爆炸负责 </b></a></li>
				</ul>
			</div>
			<h1>
				<img src="images/title_3.gif" alt="娱乐新闻" />
			</h1>
			<div class="side_list">
				<ul>
					<li><a href='#'><b> "星跳水立方"决战临近 陈楚生被华谊要求进前三 </b></a></li>
					<li><a href='#'><b> 《新恋爱时代》登东方卫视 《非诚》元素遭删除 </b></a></li>
					<li><a href='#'><b> 《海角七号》导演新片开机 吴宇森等出席 </b></a></li>
					<li><a href='#'><b> 《致命黑兰》佐伊坐拥7种武器 暴力登陆全国院线 </b></a></li>
				</ul>
			</div>
		</div>
		<div class="main">
			<div class="class_type">
				<img src="images/class_type.gif" alt="新闻中心" />
			</div>
			<div class="content">
				<ul class="class_date">
					<c:forEach var="topic" items="${applicationScope['ALL_TOPICS'] }"
						varStatus="status">
						<c:choose>
							<c:when test="${status.count %11==1 }">
								<li id='class_month'><a href="#"><b>${topic.tname }</b></a>
							</c:when>
							<c:when test="${status.count %11==0 or status.last}">
								<a href="#"><b>${topic.tname }</b></a>
								</li>
							</c:when>
							<c:otherwise>
								<a href="#%>"><b>${topic.tname }</b></a>
							</c:otherwise>
						</c:choose>
					</c:forEach>
				</ul>
				<ul class="classlist">
					<%
				   	NewsService newsService = new  NewsServiceImpl();
				  	int pageIndex  =Integer.parseInt(request.getParameter("pageIndex")==null?"1":request.getParameter("pageIndex"));
					Page pp=newsService.getAllnewsByPage(pageIndex,20);
					int totalPagecount= pp.getTotalPageCount();
					session.setAttribute("list", pp.getNewsList());
				  	%>
				  	<c:set value="0" var="n" />      
			      	<c:forEach var="news" items="${list}">
				        <li>
					        <a href='util/news_control.jsp?opr=readNew&nid=${news.nid }'>${news.ntitle }</a>
					        <span>${news.ncreatedate}</span>
				        </li>
				        <c:set var="n" value="${n+1}" />
				        <c:if test="${n%5==0}">
				        	<li class='space'></li>
				        </c:if>
			        </c:forEach>
		      		 <p align="right"> 当前页数:[<%=pageIndex %>/<%= totalPagecount%>]&nbsp;
		      		  <% 
		      		 	if(pageIndex>1){
		      		 %>		
		      		 	<a href ="index.jsp?pageIndex=1">首页</a>
		      		 	<a href ="index.jsp?pageIndex=<%=pageIndex-1%>">上一页</a>
		      		 		
		      		 <% }
		      		 	if(pageIndex<totalPagecount){
		      		 %>
		      		 	<a href ="index.jsp?pageIndex=<%=pageIndex+1%>">下一页</a>
		      		 	<a href ="index.jsp?pageIndex=<%=totalPagecount%>">末页</a>
		      		  <% 
		      		 	}
		      		 %>
		      		 </p>
				</ul>
			</div>
			<div class="picnews">
				<ul>
					<li><a href="#"><img src="images/Picture1.jpg" width="249"
							alt="" /> </a><a href="#">幻想中穿越时空</a></li>
					<li><a href="#"><img src="images/Picture2.jpg" width="249"
							alt="" /> </a><a href="#">国庆多变的发型</a></li>
					<li><a href="#"><img src="images/Picture3.jpg" width="249"
							alt="" /> </a><a href="#">新技术照亮都市</a></li>
					<li><a href="#"><img src="images/Picture4.jpg" width="249"
							alt="" /> </a><a href="#">群星闪耀红地毯</a></li>
				</ul>
			</div>
		</div>
	</div>
	<%@include file="index-elements/index_bottom.html"%>
</body>
</html>
